<!-- 样式 -->
<script type="text/html" template>
    <link rel="stylesheet" href="{{ layui.setter.base }}style/css/reset.css">
    <link rel="stylesheet" href="{{ layui.setter.base }}style/css/home/datailed.css">
</script>
<style scoped>
.layui-form-radio i{
    font-size: 15px;
    margin-left: 20px;
}
.layui-form-radio{
    margin: 0;
    padding: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    vertical-align: middle;
    height: 20px;
    line-height: 20px;
}
.layui-form-radio div{
    margin: 0;
    font-size: 11px;
}
#myupload{
    display: flex;
    justify-content: flex-start;
    align-items: center;
    flex-wrap: wrap;
}
#mytitle{
    flex-basis: 100%;
}
#upload{
    display: inline-block;
    width: 52px;
    height: 52px;
    margin: 0;
    margin-bottom: 10px;
}
.upload-img{
    position: relative;
}
.del_img{
    border-radius: 10px;
    border: 1px solid #FF5722;
    font-size: 15px;
    color: #FF5722;
    position: absolute;
    z-index: 9;
    right: 5px;
    top: 0;
    cursor: pointer;
    text-align: center;
}
</style>
<div class="layui-containner">
    <div class="layui-fluid">
        <div id="view-one" class="layui-form" lay-filter="form"></div>
        <div class="layui-tab" overflow>
            <ul class="layui-tab-title">
                <li class="layui-this">相关工单</li>
                <li>状态变更记录</li>
                <li>相关文档</li>
                <li>关联备品备件</li>
                <li>备品备件消耗记录</li>
                <li>信息变更记录</li>
                <li>设备履历</li>
                <li>Scada</li>
                <li>请采购记录</li>
                <li>设备参数</li>
            </ul>
            <div class="layui-tab-content">
                <!-- 相关工单 -->
                <div class="layui-tab-item layui-show">
                    <div class="icon-box layui-btn-containner">
                    </div>
                    <table class="layui-table" id="table_one"></table>
                </div>
                <!-- 状态变更记录 -->
                <div class="layui-tab-item">
                    <div class="icon-box layui-btn-containner">
                    </div>
                    <table class="layui-table" id="table_two"></table>
                </div>
                <!-- 相关文档 -->
                <div class="layui-tab-item">
                    <div class="icon-box layui-btn-containner">
                    </div>
                    <table class="layui-table" id="table_three" lay-filter="demo"></table>
                </div>
                <!-- 关联备品备件 -->
                <div class="layui-tab-item">
                    <div class="icon-box layui-btn-containner">
                    </div>
                    <table class="layui-table" id="table_fore"></table>
                </div>
                <!-- 备品备件消耗记录 -->
                <div class="layui-tab-item">
                    <div class="icon-box layui-btn-containner">
                    </div>
                    <table class="layui-table" id="table_five"></table>
                </div>
                <!-- 信息变更记录 -->
                <div class="layui-tab-item">
                    <div class="icon-box layui-btn-containner">
                    </div>
                    <table class="layui-table" id="table_six"></table>
                </div>
                <!-- 设备履历 -->
                <div class="layui-tab-item">
                    <div class="icon-box layui-btn-containner">
                    </div>
                    <table class="layui-table" id="table_seven"></table>
                </div>
                <!-- Scada -->
                <div class="layui-tab-item">
                    <div class="icon-box layui-btn-containner">
                    </div>
                    <table class="layui-table" id="table_eight"></table>
                </div>
                <!-- 请采购记录 -->
                <div class="layui-tab-item">
                    <div class="icon-box layui-btn-containner">
                    </div>
                    <table class="layui-table" id="table_nine"></table>
                </div>
                <!-- 设备参数 -->
                <div class="layui-tab-item">
                    <div class="icon-box layui-btn-containner">
                    </div>
                    <table class="layui-table" id="table_ten"></table>
                </div>
            </div>
        </div>
    </div>
</div>
<script type="text/html" id="list-one">
        <div class="layui-title">
            <span class="layui-title-inner">设备基本信息</span>
        </div>
        <ul class="box layui-row">
            <li class="layui-col-md3 layui-col-sm3">
                <div data-id="{{d.tcScadaId}}" id="tcScadaId">设备ID：{{ d.tcDevId }}</div>
                <div>设备编号:{{ d.fia01 }}</div>
                {{#  if(d.fiaacti == 0){ }}
                <div>设备状态：一般</div>
                {{#  } else if(d.fiaacti == 1) { }}
                <div>设备状态：良好</div>
                {{#  } else if(d.fiaacti == 2) { }}
                <div>设备状态：不稳定</div>
                {{#  } else if(d.fiaacti == 3) { }}
                <div>设备状态：折旧中</div>
                {{#  } else if(d.fiaacti == 4) { }}
                <div>设备状态：外送</div>
                {{#  } else if(d.fiaacti == 5) { }}
                <div>设备状态：折毕</div>
                {{#  } else if(d.fiaacti == 6) { }}
                <div>设备状态：出售</div>
                {{#  } else if(d.fiaacti == 7) { }}
                <div>设备状态：报废</div>
                {{#  } else if(d.fiaacti == 8) { }}
                <div>设备状态：折毕再提</div>
                {{#  } else if(d.fiaacti == 9) { }}
                <div>设备状态：改良</div>
                {{#  } else if(d.fiaacti == A) { }}
                <div>设备状态：重估</div>
                {{#  } else if(d.fiaacti == null) { }}
                <div></div>
                {{# } }}
                {{#  if(d.azp02 == null){ }}
                <div></div>
                {{#  } else{ }}
                <div>所属公司：{{ d.azp02 }}</div>
                {{# } }}
                {{#  if(d.fia011 == null){ }}
                <div></div>
                {{#  } else{ }}
                <div>资产编号：{{ d.fia011 }}</div>
                {{# } }}
            </li>
            <li class="layui-col-md3 layui-col-sm3">
                {{#  if(d.fia02  == null){ }}
                <div></div>
                {{#  } else{ }}
                <div>设备名称：{{ d.fia02 }}</div>
                {{# } }}
                {{#  if(d.fic02  == null){ }}
                <div></div>
                {{#  } else{ }}
                <div data-name="{{ d.fic02 }}">设备类型:{{ d.fic02 }}</div>
                {{# } }}
                {{#  if(d.fii02  == null){ }}
                <div></div>
                {{#  } else{ }}
                <div id="model" data-name="{{ d.fii02 }}">设备型号:{{ d.fii02 }}</div>
                {{# } }}
                {{#  if(d.tcSeriesName  == null){ }}
                <div></div>
                {{#  } else{ }}
                <div>设备系列:{{ d.tcSeriesName }}</div>
                {{# } }}
                {{#  if(d.pmc081  == null){ }}
                <div></div>
                {{#  } else{ }}
                <div>供应商:{{ d.pmc081 }}</div>
                {{# } }}
            </li>
            <li class="layui-col-md3 layui-col-sm3">
                {{#  if(d.fia18  == null){ }}
                <div>购买日期</div>
                {{#  } else{ }}
                <div>购买日期:{{ d.fia18 }}</div>
                {{# } }}
                {{#  if(d.fia19  == null){ }}
                <div>启动日期</div>
                {{#  } else{ }}
                <div>启动日期:{{ d.fia19 }}</div>
                {{# } }}
                {{#  if(d.fia20  == null){ }}
                <div>保修日期:</div>
                {{#  } else{ }}
                <div>保修日期:{{ d.fia20 }}</div>
                {{# } }}
                {{#  if(d.tcDevChkdate == null){ }}
                <div>验收日期:</div>
                {{#  } else{ }}
                <div>验收日期:{{ d.tcDevChkdate }}</div>
                {{# } }}
            </li>
            <li class="layui-col-md3 layui-col-sm3" id="myupload">
                <div id="mytitle">设备图片</div>
                {{# layui.each(d.paths, function(index, item){ }}
                <div class="upload-img">
                    <i class="layui-icon layui-icon-close del_img"></i>  
                    <img src="{{ d.host }}{{ item.tcFilePath }}" data-id="{{ item.tcPicId }}"> 
                </div>
                {{# }); }}
                <button type="button" class="layui-btn layui-btn-primary layui-btn-sm" id='upload'>
                    <i class="layui-icon">&#xe654;</i>
                </button>
            </li>
        </ul>
        <div class="layui-fluid">
            <div class="layui-title">
                <span class="layui-title-inner">设备位置及其相关部门.人员</span>
            </div>
            <ul class="box layui-row">
                <li class="layui-col-md3 layui-col-sm3">
                    {{#  if(d.tcFtyName == null){ }}
                    <div></div>
                    {{#  } else{ }}
                    <div>所在厂房：{{ d.tcFtyName }}</div>
                    {{# } }}
                    {{#  if(d.tcFlrName == null){ }}
                    <div></div>
                    {{#  } else{ }}
                    <div>所在楼层：{{ d.tcFlrName }}</div>
                    {{# } }}
                </li>
                <li class="layui-col-md3 layui-col-sm3">
                    {{#  if(d.tcLineName == null){ }}
                    <div></div>
                    {{#  } else{ }}
                    <div>站别线别：{{ d.tcLineName }}</div>
                    {{# } }}
                    {{#  if(d.gem02 == null){ }}
                    <div></div>
                    {{#  } else{ }}
                    <div>负责部门：{{ d.gem02 }}</div>
                    {{# } }}
                </li>
                <li class="layui-col-md3 layui-col-sm3">
                    {{#  if(d.keeper == null){ }}
                    <div></div>
                    {{#  } else{ }}
                    <div>保管人：{{ d.keeper }}</div>
                    {{# } }}
                    {{#  if(d.mover == null){ }}
                    <div></div>
                    {{#  } else{ }}
                    <div>设备调机人员：{{ d.mover }}</div>
                    {{# } }}
                </li>
            </ul>
        </div>
        <div id='view-fore'></div>
        <div class="layui-fluid" id="project">
            <div class="layui-title">
                <span class="layui-title-inner">设备说明</span>
            </div>
            <ul class="box layui-row" id="min_h">
                <li class="layui-col-md3 layui-col-sm3 ">
                    <div class="layui-form-item">
                        <label class="layui-form-label">精度：</label>
                        <div class="layui-input-block">
                            {{#  if(d.tcDevPrecision != null){ }}
                            <input type="text" name="tcDevPrecision"  data-name="精度" autocomplete="off" class="layui-input" value="{{d.tcDevPrecision}}" lay-verType="tips" lay-reqText="不能为空!">
                            {{#  } else{ }}
                            <input type="text" name="tcDevPrecision"  data-name="精度" autocomplete="off" class="layui-input" value="" lay-verType="tips" lay-reqText="不能为空!">
                            {{# } }}
                        </div>
                    </div>
                    <div id="view-two"></div>
                    <div id="view-three"></div>
                </li>
                <li class="layui-col-md3 layui-col-sm3">
                    <div class="layui-form-item layui-form-text">
                        <label class="layui-form-label">安全说明:</label>
                        <div class="layui-input-block layui-form-text">
                            {{#  if(d.fia25 != null){ }}
                            <textarea name="fia25" class="text layui-textarea" data-name="安全说明" lay-reqText="不能为空!">{{ d.fia25 }}</textarea>
                            {{#  } else{ }}
                            <textarea name="fia25" class="text layui-textarea" data-name="安全说明" lay-reqText="不能为空!"></textarea>
                            {{# } }}
                        </div>
                    </div>
                </li>
                <li class="layui-col-md3 layui-col-sm3 ">
                    <div class="layui-form-item layui-form-text">
                        <label class="layui-form-label">备注:</label>
                        <div class="layui-input-block">
                            {{#  if(d.fia22 != null){ }}
                            <textarea name="fia22" data-name="备注" class="text layui-textarea"  lay-reqText="不能为空!">{{ d.fia22 }}</textarea>
                            {{#  } else{ }}
                            <textarea name="fia22" data-name="备注" class="text layui-textarea"  lay-reqText="不能为空!"></textarea>
                            {{# } }}
                        </div>
                    </div>
                </li>
            </ul>
        </div>
        <div id='view-five'class="layui-form" lay-filter="form_five"></div>
        </form>
        <div class="edit-btn-box layui-btn-container layui-form-item">
            <div class="layui-input-block">
                <button style="background-color: #296DBB;cursor:pointer;" class="commit" lay-submit lay-filter="LAY-submit-bc">保存</button>
                <button style="background-color: #8A8A8A;cursor:pointer;" class="quxiao" lay-filter="LAY-submit-qx">取消</button>
            </div>
        </div>
</script>
<script type="text/html" id="list-fore">
        <div class="layui-fluid">
            <div class="layui-title">
                <span class="layui-title-inner">相关参数</span>
            </div>
            <ul class="box layui-row">
                <li class="layui-col-md3 layui-col-sm3">
                    {{# layui.each(d.list, function(index, item){ }}
                        <div class="layui-form-item">
                            <label class="Machine layui-form-label">{{ item.tcParName }}:：</label>
                            <div class="layui-input-block">
                                <input type="text" name="tcParValue"  autocomplete="off" class="layui-input input" value="{{ item.tcParValue }}" lay-verType="tips" lay-reqText="不能为空!"data-name="{{ item.tcParName }}" disabled style="border:0;">{{ item.tcParUnit }}
                            </div>
                        </div>
                    {{# }); }}
                </li>
            </ul>
        </div>
</script>
<script type="text/html" id="list-five">
         <div class="last-list layui-fluid">
            <div class="layui-title">
                <span class="layui-title-inner">Scada
                </span>
            </div>
            <ul class="box layui-row">
                <li class="layui-col-md3 layui-col-sm3">
                    <div class="layui-form-item">
                        <label class="layui-form-label" data-name="是否联机">是否联机:</label>
                        <div class="select layui-input-block">
                            {{# if(d.tcScadaIsonine == null) { }}
                            <input type="radio" name="tcScadaIsonine" value="N" title="否" checked>
                            <input type="radio" name="tcScadaIsonine" value="Y" title="是">
                            {{# }else if(d.tcScadaIsonine == 'N'){ }}
                            <input type="radio" name="tcScadaIsonine" value="{{ d.tcScadaIsonine }}" title="否" checked>
                            <input type="radio" name="tcScadaIsonine" value="Y" title="是">
                            {{#  } else if(d.tcScadaIsonine == 'Y') { }}
                            <input type="radio" name="tcScadaIsonine" value="N" title="否" >
                            <input type="radio" name="tcScadaIsonine" value="{{ d.tcScadaIsonine }}" title="是" checked>
                            {{#  } }}
                        </div>
                    </div>
                    {{#  if(d.tcScadaDrvtype != null){ }}
                    <div class="layui-form-item">
                        <label class="layui-form-label" data-name="驱动类型">驱动类型：</label>
                        <div class="select layui-input-block">
                            <input type="text" name="tcScadaDrvtype" autocomplete="off" class="layui-input" value="{{ d.tcScadaDrvtype }}" lay-verType="tips" lay-reqText="不能为空!" disabled style="border:0;">
                        </div>
                    </div>
                        {{#  } else { }}
                        <div class="layui-form-item">
                            <label class="layui-form-label" data-name="驱动类型">驱动类型：</label>
                            <div class="select layui-input-block">
                                <input type="text" name="tcScadaDrvtype" autocomplete="off" class="layui-input" value="" lay-verType="tips" lay-reqText="不能为空!" disabled style="border:0;">
                            </div>
                        </div>
                        {{#  } }}  
                        {{#  if(d.tcScadaDrvname != null){ }}
                        <div class="layui-form-item">
                            <label class="layui-form-label" data-name="驱动名称">驱动名称：</label>
                            <div class="select layui-input-block">
                                <input type="text" name="tcScadaDrvname" autocomplete="off" class="layui-input" value="{{ d.tcScadaDrvname }}" lay-verType="tips" lay-reqText="不能为空!" disabled style="border:0;">
                            </div>
                        </div>
                        {{#  } else { }}
                        <div class="layui-form-item">
                            <label class="layui-form-label" data-name="驱动名称">驱动名称：</label>
                            <div class="select layui-input-block">
                                <input type="text" name="tcScadaDrvname" autocomplete="off" class="layui-input" value="" lay-verType="tips" lay-reqText="不能为空!" disabled style="border:0;">
                            </div>
                        </div>
                        {{#  } }} 
                </li>
                <li class="layui-col-md3 layui-col-sm3">
                    <div class="layui-form-item">
                        <label class="layui-form-label">设备IP：</label>
                        <div class="layui-input-block">
                            {{#  if(d.tcScadaIpaddress != null){ }}
                            <input type="text" name="tcScadaIpaddress" data-name="设备IP" autocomplete="off" class="layui-input" value="{{d.tcScadaIpaddress}}" lay-verType="tips" lay-reqText="不能为空!" disabled style="border:0;">
                            {{#  } else { }}
                            <input type="text" name="tcScadaIpaddress" data-name="设备IP"  autocomplete="off" class="layui-input" value="" lay-verType="tips" lay-reqText="不能为空!" disabled style="border:0;">
                            {{#  } }} 
                        </div>
                    </div>
                    {{#  if(d.tcScadaProdtime != null){ }}
                    <div>正常生产时长：{{ d.tcScadaProdtime }}</div>
                    {{#  } else { }}
                    <div>正常生产时长：</div>
                    {{#  } }} 
                    {{#  if(d.tcScadaProdtime != null){ }}
                    <div>待机时长：{{ d.tcScadaStdbytime }}</div>
                    {{#  } else { }}
                    <div>待机时长：</div>
                    {{#  } }} 
                </li>
                <li class="layui-col-md3 layui-col-sm3">
                    {{#  if(d.tcScadaExcptime != null){ }}
                    <div>异常时长：{{ d.tcScadaExcptime }}</div>
                    {{#  } else { }}
                    <div>异常时长：</div>
                    {{#  } }} 
                    {{#  if(d.tcScadaMainttime != null){ }}
                    <div>维修保养时长：{{ d.tcScadaMainttime }}</div>
                    {{#  } else { }}
                    <div>维修保养时长：</div>
                    {{#  } }} 
                    {{#  if(d.tcScadaProduction != null){ }}
                    <div>产量：{{ d.tcScadaProduction }}</div>
                    {{#  } else { }}
                    <div>产量：</div>
                    {{#  } }} 
                </li>
            </ul>
        </div>
    </script>
<script type="text/html" id="typeTpl">
        {{#  if(d.fil04 == 'WX' ){ }}
        <div>设备维修工单</div>
        {{#  } else if(d.type == 'BY' ) { }}
        <div>设备保养工单</div>
        {{#  } else if(d.fil04 == 'XJ' ) { }}
        <div>设备巡检计划</div>
        {{#  } else if(d.fil04 == 'DB' ) { }}
        <div>设备调拨工单</div>
        {{#  } else if(d.fil04 == 'BF' ) { }}
        <div>设备报废工单</div>
        {{#  } else if(d.fil04 == 'TY' ) { }}
        <div>设备停用工单</div>
        {{#  } else if(d.fil04 == 'QY' ) { }}
        <div>设备启用工单</div>
        {{#  } else if(d.fil04 == 'BG' ) { }}
        <div>设备信息变更工单</div>
        {{#  } else if(d.fil04 == 'SP' ) { }}
        <div>备品备件借调工单</div>
        {{#  } else if(d.fil04 == 'PD' ) { }}
        <div>设备盘点</div>
        {{#  } }}
    </script>
<script type="text/html" id="typeTpl_one">
        {{#  if(d.fil05 == 0 ){ }}
        <div>创建/未提交</div>
        {{#  } else if(d.fil05 == 1 ) { }}
        <div>待审核(已提交)</div>
        {{#  } else if(d.fil05 == 2 ) { }}
        <div>待执行(已派单)/未完成</div>
        {{#  } else if(d.fil05 == 3 ) { }}
        <div>外修(维修工单)</div>
        {{#  } else if(d.fil05 == 4 ) { }}
        <div>待确认</div>
        {{#  } else if(d.fil05 == 5 ) { }}
        <div>待领料</div>
        {{#  } else if(d.fil05 == 6 ) { }}
        <div>OA送审中</div>
        {{#  } else if(d.fil05 == 9 ) { }}
        <div>归档/已盘点</div>
        {{#  } }}
    </script>
<script type="text/html" id="list-two">
        {{# layui.each(d, function(index, item){ }}
        <div class="layui-form-item">
            <label class="Machine layui-form-label">机台能力：</label>
            <div class="layui-input-block">
                <input type="text" name="tcCapName"  autocomplete="off" class="layui-input" value="{{ this.tcCapName }}" lay-verType="tips" lay-reqText="不能为空!" data-name='机台能力' disabled style="border:0;width:auto">
            </div>
        </div>
        {{# }); }}
</script>
<script type="text/html" id="list-three">
        {{# layui.each(d, function(index, item){ }}
        <div class="layui-form-item">
            <label class="production layui-form-label">生产能力：</label>
            <div class="layui-input-block">
                <input type="text" name="tcProdName"  autocomplete="off" class="layui-input" value='{{ this.tcProdName }}' lay-verType="tips" lay-reqText="不能为空!" data-name="生产能力" disabled style="border:0;width:auto">
            </div>
        </div>
        {{# }); }}
    </script>
<script type="text/html" id="down">
        <span class="table-eys" lay-event="look"></span>
        <span class="table-down" lay-event="Down"></span>
    </script>
<script>
    var img_url = [];
    var fia01 = '';
    layui.use(['table', 'admin', 'laypage', 'jquery', 'laytpl', 'tree', 'form', 'api', 'view', 'laydate', 'setter', 'treeSelect', "element", 'utill','upload'], function () {
        var table = layui.table;
        var admin = layui.admin;
        var laypage = layui.laypage;
        var $ = layui.jquery;
        var laytpl = layui.laytpl;
        var tree = layui.tree;
        var form = layui.form;
        var api = layui.api;
        var view = layui.view;
        var laydate = layui.laydate;
        var setter = layui.setter;
        var utill = layui.utill;
        var treeSelect = layui.treeSelect;
        var element = layui.element;
        var upload = layui.upload;
        var router = layui.router();
        var session = JSON.parse(sessionStorage.getItem('id'));
        var str = sessionStorage.getItem('ipay-merchant')
        var token = JSON.parse(str).token;
        var id = session.id;
        form.render();
        //取消按钮
        $('#view-one').on('click', '.quxiao', function () {
            setTimeout(function () {
                var url = '/home/branch-one/detailed';
                location.hash = url;
            }, 1000)
        })
        function myradio(data,elem){
            form.on('radio()', function(data){
                data = data.value
                if(data == 'Y'){
                    elem.forEach((item)=>{
                        $(item).removeAttr('disabled');
                        $(item).css('border','1px solid #DEDEDE');
                    })
                }else{
                    elem.forEach((item)=>{
                        $(item).attr('disabled','disabled');
                        $(item).css('border','0');
                    })
                }
            })
            
            if(data == 'Y'){
                elem.forEach((item)=>{
                    $(item).removeAttr('disabled');
                    $(item).css('border','1px solid #DEDEDE');
                })
            }else{
                elem.forEach((item)=>{
                    $(item).attr('disabled','disabled');
                    $(item).css('border','0');
                })
            }
        }
        var arr_one = [];
        var arr_two = [];
        var href = JSON.parse(sessionStorage.getItem('layui-this'));
        $(href).addClass('layui-this');
        var _TPL = {
            fil04: function (d) {
                if (d.fil04 == 'WX') {
                    return '<span>设备维修工单</span>'
                } else if (d.fil04 == 'BY') {
                    return '<span>设备保养工单</span>'
                } else if (d.fil04 == 'XJ') {
                    return '<span>设备巡检工单</span>'
                } else if (d.fil04 == 'DB') {
                    return '<span>设备调拨工单</span>'
                } else if (d.fil04 == 'BF') {
                    return '<span>设备报废工单</span>'
                } else if (d.fil04 == 'TY') {
                    return '<span>设备停用工单</span>'
                } else if (d.fil04 == 'QY') {
                    return '<span>设备启用工单</span>'
                } else if (d.fil04 == 'BG') {
                    return '<span>设备变更工单</span>'
                } else if (d.fil04 == 'SP') {
                    return '<span>备品备件借调工单</span>'
                } else if (d.fil04 == 'PD') {
                    return '<span>设备盘点</span>'
                }
            },
            fil05: function (d) {
                if (d.fil05 == 0) {
                    return '<span>创建未提交</span>'
                } else if (d.fil05 == 1) {
                    return '<span>待审核</span>'
                } else if (d.fil05 == 2) {
                    return '<span>待执行</span>'
                } else if (d.fil05 == 3) {
                    return '<span>外修</span>'
                } else if (d.fil05 == 4) {
                    return '<span>待确定</span>'
                } else if (d.fil05 == 5) {
                    return '<span>待领料</span>'
                } else if (d.fil05 == 6) {
                    return '<span>OA送审</span>'
                } else if (d.fil05 == 7) {
                    return '<span>超时未完成</span>'
                } else if (d.fil05 == 8) {
                    return '<span>超时已完成</span>'
                } else if (d.fil05 == 9) {
                    return '<span>归档已盘点</span>'
                }
            }
        }
        //相关工单
        function render_one(data) {
            utill.columnCustom('#table_one', 'FiaEquipOrderVO', {
                url: api.host + api.xbxq.table1,
                type: 'post',
                where: {
                    fia01: data
                },
                checkbox: false,
                templet: _TPL,
            });
        }

        //状态变更记录
        function render_two(data) {
            table.render({
                elem: '#table_two',
                skin: 'nob',
                align: 'center',
                method: 'post',
                where: {
                    fia011: data
                },
                url: api.host + api.xbxq.table2 //数据接口
                ,
                contentType: 'application/json',
                page: {
                    count: 50,
                    limit: 10,
                    layout: ['prev', 'page', 'next', 'skip']
                },
                request: {
                    pageName: 'pageNum' //页码的参数名称，默认：page
                    ,
                    limitName: 'pageSize' //每页数据量的参数名，默认：limit
                },
                response: {
                    statusCode: 200 //重新规定成功的状态码为 200，table 组件默认为 0
                },
                parseData: function (res) { //res 即为原始返回的数据
                    return {
                        "code": 200, //解析接口状态
                        "msg": res.message, //解析提示文本
                        "data": res.data.statChgLog.list //解析数据列表
                    };
                },
                headers: { 'token': layui.sessionData(setter.tableName).token },
                cols: [
                    [{
                        type: 'numbers',
                        title: '序号',
                        align: 'center'
                    }, {
                        field: 'tcLogId',
                        title: '设备状态变更记录ID',
                        align: 'center'
                    }, {
                        field: 'tcLogTime',
                        title: '变更时间',
                        align: 'center'
                    }, {
                        field: 'tcLogStatorig',
                        title: '变更前状态',
                        align: 'center'
                    }, {
                        field: 'tcLogStatalt',
                        title: '变更后状态',
                        align: 'center'
                    }, {
                        field: 'gen02',
                        title: '操作人',
                        align: 'center'
                    }, {
                        field: 'tcLogModby',
                        title: '操作者工号',
                        align: 'center'
                    }]
                ],
            });
        }
        //相关文档
        function render_three(data) {
            utill.columnCustom('#table_three', 'FiaDocument', {
                url: api.host + api.xbxq.table3,
                type: 'post',
                where: {
                    modelid: data,
                },
                checkbox: false,
                toolbar: {
                    toolbar: '#down',
                    title: '操作',
                    event: 'detail',
                    align: 'center'
                }
            });
        }
        //关联备品备件
        function render_fore(data) {
            utill.columnCustom('#table_fore', "imaFile01", {
                url: api.host + api.xbxq.table4 //数据接口
                ,
                checkbox: false,
                where: {
                    fii02: data
                },
            });
        }
        //备品备件消耗记录
        function render_five(data) {
            table.render({
                elem: '#table_five',
                skin: 'nob',
                align: 'center',
                method: 'post',
                where: { tcDetailFia01: data },
                url: api.host + api.xbxq.table5 //数据接口
                ,
                contentType: 'application/json',
                page: {
                    count: 50,
                    limit: 10,
                    layout: ['prev', 'page', 'next', 'skip']
                },
                request: {
                    pageName: 'pageNum' //页码的参数名称，默认：page
                    ,
                    limitName: 'pageSize' //每页数据量的参数名，默认：limit
                },
                response: {
                    statusCode: 200 //重新规定成功的状态码为 200，table 组件默认为 0
                },
                parseData: function (res) { //res 即为原始返回的数据
                    return {
                        "code": 200, //解析接口状态
                        "msg": res.message, //解析提示文本
                        "data": res.data.list //解析数据列表
                    };
                },
                headers: { 'token': layui.sessionData(setter.tableName).token },
                cols: [
                    [{
                        type: 'numbers',
                        title: '序号',
                        align: 'center'
                    }, {
                        field: 'fil01',
                        title: '相关工单编号',
                        align: 'center'
                    }, {
                        field: 'fiw03',
                        title: '备品备件料件编号',
                        align: 'center'
                    }, {
                        field: 'fiv07',
                        title: '备品备件OA申请人',
                        align: 'center'
                    }, {
                        field: 'gen02',
                        title: '申请人名称',
                        align: 'center'
                    }, {
                        field: 'fim01',
                        title: '相关工单',
                        align: 'center'
                    }, {
                        field: 'fil10',
                        title: '申请时间',
                        align: 'center'
                    }, {
                        field: 'fiw08',
                        title: '数量',
                        align: 'center'
                    }]
                ],
            });
        }


        //设备信息变更记录
        function render_six(data) {
            table.render({
                elem: '#table_six',
                skin: 'nob',
                align: 'center',
                method: 'post',
                where: { fia011: data },
                url: api.host + api.xbxq.table6 //数据接口
                ,
                contentType: 'application/json',
                page: {
                    count: 50,
                    limit: 10,
                    layout: ['prev', 'page', 'next', 'skip']
                },
                request: {
                    pageName: 'pageNum' //页码的参数名称，默认：page
                    ,
                    limitName: 'pageSize' //每页数据量的参数名，默认：limit
                },
                response: {
                    statusCode: 200 //重新规定成功的状态码为 200，table 组件默认为 0
                },
                parseData: function (res) { //res 即为原始返回的数据
                    return {
                        "code": 200, //解析接口状态
                        "msg": res.message, //解析提示文本
                        "data": res.data.infoChgLog.list //解析数据列表
                    };
                },
                headers: { 'token': layui.sessionData(setter.tableName).token },
                cols: [
                    [{
                        type: 'numbers',
                        title: '序号',
                        align: 'center'
                    }, {
                        field: 'tcLogId',
                        title: '设备状态变更记录ID',
                        align: 'center'
                    }, {
                        field: 'tcLogTime',
                        title: '变更时间',
                        align: 'center'
                    }, {
                        field: 'tcLogInfoalt',
                        title: '变更前状态',
                        align: 'center'
                    }, {
                        field: 'tcLogInfoalt',
                        title: '变更后状态',
                        align: 'center'
                    }, {
                        field: 'gen02',
                        title: '操作人',
                        align: 'center'
                    }, {
                        field: 'tcLogModby',
                        title: '操作者工号',
                        align: 'center'
                    }]
                ],
            });
        }
        //设备履历
        function render_seven(data) {
            table.render({
                elem: '#table_seven',
                skin: 'nob',
                align: 'center',
                method: 'post',
                url: api.host + api.xbxq.table7 //数据接口
                ,
                where: {
                    tcDetailFia01: data
                },
                dataType: 'json',
                contentType: 'application/json',
                page: {
                    count: 50,
                    limit: 10,
                    layout: ['prev', 'page', 'next', 'skip']
                },
                request: {
                    pageName: 'pageNum' //页码的参数名称，默认：page
                    ,
                    limitName: 'pageSize' //每页数据量的参数名，默认：limit
                },
                response: {
                    statusCode: 200 //重新规定成功的状态码为 200，table 组件默认为 0
                },
                parseData: function (res) { //res 即为原始返回的数据
                    return {
                        "code": 200, //解析接口状态
                        "msg": res.message, //解析提示文本
                        "data": res.data.list //解析数据列表
                    };
                },
                headers: { 'token': layui.sessionData(setter.tableName).token },
                cols: [
                    [{
                        type: 'numbers',
                        title: '序号',
                        align: 'center'
                    }, {
                        field: 'azp02',
                        title: '原公司',
                        align: 'center'
                    }, {
                        field: 'azp021',
                        title: '新公司',
                        align: 'center'
                    }, {
                        field: 'fim01',
                        title: '相关工单',
                        align: 'center'
                    }, {
                        field: 'gen02',
                        title: '申请人',
                        align: 'center'
                    }]
                ],
            });
        }
        // //请采购记录
        function render_nine(data) {
            utill.columnCustom('#table_nine', 'FiaPmmAndPmnVo', {
                url: api.host + api.xbxq.table9,
                type: 'post',
                checkbox: false,
                where: { tcDevId: data }
            });
        }
        //设备参数
        function render_ten(data) {
            utill.columnCustom('#table_ten', "FiaFileParametersVO", {
            url: api.host + api.xbxq.table10,
            where: {
                fia011: data
            }
            });
        }
        admin.req({
            type: 'get',
            url: api.host + api.xxxx.views_one,
            dataType: 'json',
            contentType: "application/json",
            data: { id },
            success: function (data) {
                //请求成功时处理
                var data = data.data;
                data.host = api.imghost + "/";
                element.on('tab', function (elem, e) {
                    if (elem.index == 1) {
                        render_two(id);
                    } else if (elem.index == 2) {
                        return index = data.index;
                    } else if (elem.index == 3) {
                        render_two(id);
                    } else if (elem.index == 4) {

                    } else if (elem.index == 5) {
                        render_six(id);
                    } else if (elem.index == 6) {

                    } else if (elem.index == 7) {

                    } else if (elem.index == 8) {
                        render_nine(id);
                    } else if (elem.index == 9) {

                    }
                });
                var fia011 = data.fii02;
                render_one(data.fia01);
                render_three(data.tcModelId);
                render_fore(fia011)
                render_seven(data.fia01);
                render_five(data.fia01);
                render_ten(fia011);
                laytpl($('#list-one').html()).render(data, function (html) {
                        $('#view-one').html(html)
                });
                fia01 = data.fia01;
                upload.render({
                    elem: '#upload',
                    url: api.host + '/fia/upload.json',
                    headers: {token: layui.sessionData(setter.tableName).token},
                    method: 'POST',
                    field: 'file',
                    data: {fia01: data.fia01},
                    accept: 'images',
                    acceptMime:  'image/jpg,image/png',
                    auto: true,
                    choose: function(obj){
                        obj.preview(function(index, file, result){
                            let img = `<div class="upload-img">
                                <i class="layui-icon layui-icon-close del_img"></i>  
                                <img src="${result}" data-name="${file.name}">
                            </div>`;
                            $('#upload').before(img);
                        })
                    },
                    done: function(res, index, upload){
                        if(res.data[0] != ''){
                            $('#upload').prev().attr('data-url',res.data[0]);
                            img_url.push(res.data[0]);
                        }
                    }
                });
                $('#view-one').on('click','.del_img',function(){
                    layer.confirm('确定删除吗', ()=>{
                        layer.closeAll();
                        let index  = $(this).next().attr('data-name');
                        let elem = $(this).parent();
                        if(index){
                            elem.remove()
                        }else{
                            let tcPicId = $(this).next().attr('data-id');
                            admin.req({
                                url: api.host + '/fia/deletePic.json',
                                type: 'get',
                                dataType: 'json',
                                contentType: "application/json",
                                data: {tcPicId:tcPicId},
                                success:function(res){
                                    if(res.code == 0){
                                        elem.remove();
                                    }else{
                                        layer.open({
                                            content: res.message
                                        });
                                    }
                                }
                            })
                        }
                    })
                })
                admin.req({
                    url: api.host + api.xxxx.views_two,
                    type: 'get',
                    dataType: 'json',
                    contentType: "application/json",
                    data: { id },
                    success: function (data) {
                        //请求成功时处理
                        var data = data.data;
                        laytpl($('#list-two').html()).render(data, function (html) {
                                $('#view-two').html(html);
                                admin.req({
                                    url: api.host + api.xxxx.views_three,
                                    type: 'get',
                                    dataType: 'json',
                                    contentType: "application/json",
                                    data: { id },
                                    success: function (data) {
                                        //请求成功时处理
                                        var data = data.data;
                                        laytpl($('#list-three').html()).render(data, function (html) {
                                            $('#view-three').html(html)
                                            admin.req({
                                                url: api.host + api.xxxx.views_fore,
                                                type: 'post',
                                                dataType: 'json',
                                                contentType: 'application/json',
                                                data: JSON.stringify({ fia011, pageNum: 0, pageSize: 0 }),
                                                success: function (data) {
                                                    var data = data.data;
                                                        if (data != '') {
                                                            laytpl($('#list-fore').html()).render(data, function (html) {
                                                                $('#view-fore').html(html)
                                                            });
                                                        }
                                                },
                                            });
                                        });
                                        $(data).each(function (i, data) {
                                            arr_two[i] = data.tcProdId;
                                        });
                                        element.render();
                                    },
                                });
                            });
                        $(data).each(function (i, data) {
                            arr_one[i] = data.tcCapId;
                        });
                        element.render();
                    },
                });
            },
        });
        admin.req({
            type: 'get',
            url: api.host + api.xxxx.views_one,
            dataType: 'json',
            contentType: "application/json",
            data: { id },
            success: function (data) {
                var data = data.data;
                laytpl($('#list-five').html()).render(data, function (html) {
                        $('#view-five').html(html)
                    });
                form.render()
                let res = form.val("form").tcScadaIsonine;
                myradio(res,['[name="tcScadaDrvtype"]','[name="tcScadaDrvname"]','[name="tcScadaIpaddress"]'])
            }
        });
        table.on("tool(demo)", function (obj) {
            var data = obj.data;
            layui.sessionData("demo", {
                key: "tableobj",
                value: data
            });
            var tableobj = layui.sessionData("demo").tableobj;
            switch (obj.event) {
                case "Down":
                    window.open(
                        api.host + "/do/downloads.json?ids=" + data.tcDocId + '&token=' + token
                    );
                    break;
                case "look":
                    var htmls = ''
                    for (var i = 0; i < data.tcEamFile.length; i++) {
                        htmls += '<div style="padding: 20px;"><a target="_blank" href="' + api.imghost + '/' + data.tcEamFile[i].tcFileUrl + '" ><p>' + data.tcEamFile[i].tcFileName + data.tcEamFile[i].tcFileType + '</p></a></div>'
                    }
                    layer.open({
                        type: 1
                        , offset: 'auto'
                        , id: 'layerDemo'
                        , content: htmls
                        , btn: '关闭全部'
                        , btnAlign: 'c' //按钮居中
                        , shade: 0 //不显示遮罩
                        , yes: function () {
                            layer.closeAll();
                        }
                    });
            }
        });
        var tcScadaIsonine;
        form.on('submit(LAY-submit-bc)', function (data) {
            var val = [];
            var name = [];
            var val_two = [];
            var val_three = [];
            var capaCityParams = new Array();
            var productParams = new Array();
            var tcParName = {};
            var tcParValue = {};
            var obj = {};
            if (data.field.tcScadaIsonine == '是') {
                data.field.tcScadaIsonine = 'Y';
            } else if (data.field.tcScadaIsonine == '否') {
                data.field.tcScadaIsonine = 'N';
            }
            $('#view-fore input').each(function (i) {
                val[i] = $('#view-fore input').eq(i).val();
                name[i] = $('#view-fore input').eq(i).data('name');
            });
            $('#view-two input').each(function (i) {
                val_two[i] = $('#view-two input').eq(i).val();
            });
            $('#view-three input').each(function (i) {
                val_three[i] = $('#view-three input').eq(i).val();
            });
            $(val_two).each(function (i) {
                var one = new Object();
                one.fii02 = fii02;
                one.tcCapId = arr_one[i];
                one.tcCapName = val_two[i];
                capaCityParams.push(one);
            });
            $(val_three).each(function (i) {
                var two = new Object();
                two.fii02 = fii02;
                two.tcProdId = arr_two[i];
                two.tcProdName = val_three[i];
                productParams.push(two);
            });
            var fii02 = $('#model').data('name');
            var parameterParams = new Array();
            $(name).each(function (i) {
                var project = new Object();
                project.tcParName = name[i];
                project.tcParValue = val[i];
                project.tcParFii02 = fii02;
                parameterParams.push(project);
            });
            obj.fii02 = fii02;
            obj.tcDevId = id;
            var tcScadaId = $('#tcScadaId').data('id');
            $('#view-fore input').each(function (i) {
                obj_two = val[i] + name[i];
            });
            var obj_one = {
                "capaCityParams": capaCityParams,
                "fia22": data.field.fia22,
                "fia25": data.field.fia25,
                "parameterParams": parameterParams,
                "productParams": productParams,
                "tcDevId": id,
                "tcDevPrecision": data.field.tcDevPrecision,
                "tcScadaIpAddress": data.field.tcScadaIpaddress,
                "tcScadaId": tcScadaId,
                "tcScadaIsOnine": data.field.tcScadaIsonine,
                "tcScadaDrvType": data.field.tcScadaDrvtype,
                "tcScadaDrvName": data.field.tcScadaDrvname,
                "url": img_url?img_url: '',
                "fia01" : fia01
            };
            admin.req({
                url: api.host + api.xxxx_edit.edit,
                type: 'post',
                dataType: 'json',
                contentType: "application/json",
                data: JSON.stringify(obj_one),
                success: function (data) {
                    if (data.message == '修改成功') {
                        layer.msg(data.message);
                        var url = 'home/branch-one/detailed';
                        $('.layui-containner').attr('href', url);
                        setTimeout(function () {
                            var url = '/home/branch-one/detailed';
                            location.hash = url;
                        }, 1000)
                    }
                },
                error: function (data) {
                    layer.msg(data.message + ',请重新输入!');
                }
            });
        });
        $(".production:not(:first)").css('visibility', 'hidden');
        $('.Machine:not(:first)').css('visibility', 'hidden');

    });
</script>